import { checkUserName, checkPassWord } from './utils/main.js'
import './css/index.css'
const unameResult = checkUserName('itheima007')
const pwdResult = checkPassWord('7654321')
console.log(unameResult, pwdResult)

document.querySelector('.login-btn').addEventListener('click',()=>{
  const username = document.querySelector('.username').value
  const password = document.querySelector('.password').value
  if(!checkUserName(username)){
    alert('您输入的用户名不符合规范')
  }
  if (!checkUserName(password)) {
    alert('您输入的密码不符合规范')
  }
  console.log('用户名和密码长度符合要求')
  axios({
    url: 'http://hmajax.itheima.net/api/register',
    method: 'POST',
    data: {
      username,
      password
    }
  }).then(result => {
    alert(result.data.message)
  }).catch(error => {
    alert(error.response.data.message)
  })
})

const arr = [1, 2, 3]
const result = arr.map(val => val + 1)
console.log(result)